home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / MENU-HOT.DMO < prev    next >
Text File  |  1996-07-04  |  12KB  |  261 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   MENU-HOT.DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16.  
  17. fTmenuHOT% ( I$(1), LastI% H$(1), O?(1), T%(1), Exet$, SN% )
  18.  
  19. There are 4 arrays that control fTmenuHOT%. Each of them should be
  20. DIMed from element ZERO and, in there own way, control a particular
  21. part of the function.
  22.  
  23. I$()   Element 0 holds the command string for the menu.
  24.        All other items hold the items of the menu.
  25.  
  26. LastI% IF < 1 THEN LastI% = UBOUND( I$(1) )
  27.  
  28. H$()   IF UBOUND( H$(1) ) > 0 THEN
  29.          fHelpLine$ is used to save the area used for item help
  30.          item by item help is display with each selection
  31.          help area is restored
  32.        ELSE
  33.          No help is displayed
  34.        END IF
  35.  
  36. O?()   This array MUST equal or greater in elements to LastI%
  37.        IF O?(i%) > 0 THEN
  38.          The item is considered to be in an "ON" status
  39.          The value of O?(i%) is the ASCII value of the "HOT-KEY" or
  40.            search key (the 1st character of the item)
  41.        ELSE
  42.           The item is considered to be in an "OFF" status and the user
  43.           will not be able to select that/those item(s)
  44.       END IF
  45.  
  46. T%()  LastT% = UBOUND( T%(1) )
  47.       IF LastT% = 0 THEN
  48.           No "tagging" is preformed and the function returns the "hit"
  49.            item number
  50.        ELSE
  51.          The function returns the number of items that are ON
  52.          <F-4> will turn all items "OFF"
  53.          <F-9> will turn all items "ON"
  54.          IF LastT% => LastI% THEN
  55.              All items can be tagged (ON/OFF) and <ENTER> will exit
  56.              Each item has an array element that will either be ZERO/OFF
  57.                or > ZERO/ON
  58.            ELSEif LastT% < LastI%
  59.              T%(i%) = Tagged Item N° in the order they were tagged
  60.              IF LastT% < LastI% THEN
  61.                The function automatically exits when the array is full
  62.                <F-9> is not functional in this case
  63.              END IF
  64.          END IF
  65.        END IF
  66.  
  67. Exet$ holds any key-presses you require to exit the function
  68.       ie: Exet$ = CHR$(027,0,0,068) would exit on <ESC> and <F-10>
  69.  
  70. Sn%   The element number to start at
  71.         ZERO will result in the 1st "ON" item being selected
  72.  
  73. The following TYPE is loaded from I$(0) with the following results:
  74.                            ' ┌───────────────────┐
  75.                            '┌┤ GENERAL MENU TYPE ├───────────────────────────
  76. TYPE TmenuTYPE             '│└───────────────────┘
  77.   SetUp   AS BYTE          '│ if 0 then TmenuSETUP will be called
  78.   Row     AS BYTE          '│ starting row ( box border if .Brdr > 0 )
  79.   Col     AS BYTE          '│ starting col ( box border if .Brdr > 0 )
  80.   Iwide   AS BYTE          '│ MAX item width
  81.   IRows   AS BYTE          '│ N° if item rows    1, 2, 3, 4 etc
  82.   ICols   AS BYTE          '│ N° of item columns 1, 2, 3, 4 etc
  83.   Vert    AS BYTE          '│ Vertical YES/NO
  84.   Wrap    AS BYTE          '│ Wrap ON/OFF
  85.   HKs     AS BYTE          '│ 0 = NONE : 1 = ALPHA : 2 = HOT-KEY : >2 = TAG
  86.   '─────────────────────────┤
  87.   AttrN   AS BYTE          '│ Normal
  88.   AttrL   AS BYTE          '│ Letter HI-light or Tagged Item
  89.   AttrB   AS BYTE          '│ select Bar
  90.   AttrO   AS BYTE          '│ "OFF" item
  91.   '─────────────────────────┤
  92.   Srow    AS BYTE          '│ all 3 of these are computed by fTmenuBox$ when
  93.   Scol    AS BYTE          '│  .Srow > 0 else if .Srow = 0 then ignored
  94.   Srows   AS BYTE          '│  values used by fTmenuHOT% if .Srow > 0
  95.   Aattr   AS BYTE          '│  arrow attribute if > 0 else Battr used
  96.   '─────────────────────────┤
  97.   Brdr    AS BYTE          '│ Border style     SEE: TBoxDRAW
  98.   Battr   AS BYTE          '│ Border attribute
  99.   Shdo    AS BYTE          '│ Shadow style     SEE: DrawTShadow
  100.   Sattr   AS BYTE          '│ Shadow attribute
  101.   Tpos    AS BYTE          '│ Title Position
  102. END TYPE                   '└──────────────┤ 22 bytes ├──────────────────────
  103. ─────────────────────────────────────────────────────────────────────────────
  104. ───────────────────────── SOME OTHER HAPPENINGs ─────────────────────────────
  105. ─────────────────────────────────────────────────────────────────────────────
  106.  
  107. The function(s) return either:
  108.   1) A positive number if <ENTER> was pressed for the selected item
  109.   2) A negative number if a "bail out" key was pressed for the "hot" item
  110.   3) The number of Tagged items if .HKs > 2
  111.   AND
  112.   The exiting key-press is in the keyboard buffer
  113.     ie: G$ = INKEY$ will gather the key-press for you
  114.  
  115. IF any of the first 5 bytes of I$(0) = CHR$(0) THEN TmenuSETUP will be
  116.   called automatically
  117.   NOTE: if HOT KEYS are used remember:
  118.         TmenuSETUP also changes/creates the correct printable item STRs
  119.         so it cannot be called twice unless the items have been reset to
  120.         the "_Hello World" style
  121.  
  122. A menu can have any, all, or any combination of O?(), T%(), and H$():
  123.   To make life just a bit easier there are a series of functions that
  124.   automatically allow for menu calling without DIMing the "unused" arrays.
  125.  
  126.   NOTE: Even though fTmenuHOT% is a fully functional routine I would be
  127.         extremely hard pressed to conceive of a single menu that would/could
  128.         require all of it's properties to be in use at the same time.
  129.         Instead, it would be advisable to use either the ready made CALLs as
  130.         shown below or to introduce your own "specialized" routines.
  131.         eg: A menu that allowed "T"agging would normally have all it's
  132.         items in an "ON" status and would generally not use the item by
  133.         item "H"elp lines.
  134.  
  135.  In these function names: "H" = item by item Help
  136.                           "O" = item by item On/Off switching
  137.                           "T" = item tagging
  138.  the presence or absence of these letters explain the required/automatic
  139.  portions thereof.
  140.  
  141.  fTmenu%    ( I$(), LastI%, H$,               Exet$, Sn% )
  142.  fTmenuH%   ( I$(), LastI%, H$(),             Exet$, Sn% )
  143.  fTmenuHO%  ( I$(), LastI%, H$(), O?(),       Exet$, Sn% )
  144.  fTmenuHT%  ( I$(), LastI%, H$,         T%(), Exet$, Sn% )
  145.  fTmenuO%   ( I$(), LastI%, H$,   O?(), T%(), Exet$, Sn% )
  146.  fTmenuOT%  ( I$(), LastI%, H$,   O?(), T%(), Exet$, Sn% ) (questionable use)
  147.  fTmenuT%   ( I$(), LastI%, H$,         T%(), Exet$, Sn% )
  148.  fTmenuHOT% ( I$(), LastI%, H$(), O?(), T%(), Exet$, Sn% ) (questionable use)
  149.  
  150.  In the functions above H$ (as a single variable) will cause the help line
  151.  to be saved / printed with H$ / and restored upon exiting
  152.  
  153. ─────────────────────────────────────────────────────────────────────────────
  154. ──────────────────────────── A SAMPLE PROGRAM ───────────────────────────────
  155. ─────────────────────────────────────────────────────────────────────────────
  156.  
  157. Below is a simple program that will allow you to test the properties
  158. of this menu system.
  159.  
  160. NOTE: the TYPE is used here to simplify the process but in a working
  161.       program I$(0) would hold this information
  162.       I$(0) = CHR$(0,0,0,5,3,0,0,0,0,1,31,27,113,25,1,23,1,8,2) + "TITLE"
  163.  
  164. NOTE: if you are going to use "HOT KEYS" then you will not want to
  165.       have more than 26 items (normally)
  166.  
  167. $endif
  168.  
  169. $STACK